import { createStore } from 'vuex'
import createPersistedstate from 'vuex-persistedstate'
import user from './modules/user'
import cart from './modules/cart'
import category from './modules/category'



export default createStore({
  state: {
    username:'zyz',
    
  },
  mutations: {
    updateName (state) {
      state.username = 'ls'
    }
  },
  actions: {
    updateName (ctx) {
      // 发请求
      setTimeout(() => {
        ctx.commit('updateName')
      }, 1000)
    }
  },
  getters: {
    newName (state) {
      return state.username + '!!!'
    }
  },
  modules: {
    user,
    cart,
    category
  },
  plugins: [
      createPersistedstate({
        key: 'erabbit-client-pc-store',
        paths: ['user', 'cart']
      })
    ]
})

